//
// auth: Du Long
// date: 2024-09-15
// description:
//
import "package:share_image_server/export_all.dart";


ResponseApi responseApiFromJson(String str) => ResponseApi.fromJson(json.decode(str));

String responseApiToJson(ResponseApi data) => json.encode(data.toJson());

class ResponseApi {
  int code;
  String msg;
  String dataType;
  Object data;

  ResponseApi({required this.code, required this.msg, required this.dataType, required this.data});

  factory ResponseApi.fromJson(Map<String, dynamic> json) {
    Object data;
    String dataType = json["dataType"];
    switch (dataType) {
      case "Boolean":
        data = json["data"] as bool;
        break;
      case "String":
        data = json["data"] as String;
        break;
      case "Number":
        data = json["data"] as int;
        break;
      case "Array":
        data = json["data"] as List;
        break;
      case "Object":
        data = json["data"] as Object;
        break;
      default:
        data = json["data"];
        break;
    }
    return ResponseApi(code: json["code"], msg: json["msg"], dataType: json["dataType"], data: data);
  }

  Map<String, Object> toJson() => {"code": code, "msg": msg, "dataType": dataType, "data": data};
}
